package com.codingfuture.erp_system.service.impl;

import com.codingfuture.erp_system.action.Sample;
import com.codingfuture.erp_system.entity.Alert;
import com.codingfuture.erp_system.entity.StoreAlert;
import com.codingfuture.erp_system.mapper.StockAlertMapper;
import com.codingfuture.erp_system.service.StockAlertService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class StockAlertServiceImpl implements StockAlertService {

    @Autowired
    private StockAlertMapper stockAlertMapper;

    @Override
    public List<StoreAlert> findByAll() {
        return stockAlertMapper.findByAll();
    }

    @Override
    public void findBySms() {
        StringBuilder stringBuilder = new StringBuilder();
        List<Alert> alertMessage = stockAlertMapper.findBySms();
        for (Alert alert : alertMessage) {
            String goodsName = alert.getGoodsName();
            stringBuilder.append(goodsName);
        }
        try {
            Sample.main(stringBuilder);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
